CC=gcc
OBJS=main.o cpu_tool.o exec.o sar_tool.o
cpu_tool:$(OBJS)
	$(CC) -o cpu_tool $(OBJS)
main.o:main.c
	$(CC) -c main.c
cpu_tool.o:cpu_tool.c cpu_cmd.h cpu_info.h
	$(CC) -c cpu_tool.c
exec.o:exec.c
	$(CC) -c exec.c
sar_tool.o:sar_tool.c
	$(CC) -c sar_tool.c

jni:libCpuTool.so
CFLAGS= -fPIC -D_REENTRANT -I/usr/lib/jvm/default-java/include/ -I/usr/lib/jvm/default-java/include/linux 
SHARE_FLAG= -shared
LIB_OBJS=cpu_tool.o exec.o sar_tool.o cpu_tool_jni.o
libCpuTool.so:$(LIB_OBJS)
	$(CC) -o libCpuTool.so $(LIB_OBJS) $(CFLAGS) $(SHARE_FLAG)
cpu_tool_jni.o:cpu_tool_jni.c
	$(CC) -c $(CFLAGS) cpu_tool_jni.c
qt:libCpuToolQt.so
CFLAGS= -fPIC -D_REENTRANT
SHARE_FLAG= -shared
LIB_OBJS_QT=cpu_tool.o exec.o sar_tool.o
libCpuToolQt.so:$(LIB_OBJS_QT)
	$(CC) -o libCpuToolQt.so $(LIB_OBJS_QT) $(CFLAGS) $(SHARE_FLAG)

.PHONY:clean
clean:
	rm cpu_tool $(OBJS) libCpuTool.so libCpuToolQt.so
